<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>列表</title>
        <link rel="stylesheet" href="css/bootstrap.min.css"/>
        <link rel="stylesheet" href="css/style.css"/>
        <script src="js/jquery-3.4.1.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <script src="static/js/script.js" charset="UTF-8"></script>
    </head>
    <body>
        <div class="container">

            <br>
            <h1 class="text-center text-success">${requestScope.batchName}列表</h1>
            <br>


            <table id="dataTable" class="table table-hover">
                <tr>
                    <td colspan="6" class="title" style="width: 80%;">
                        <button id="btn_showAddModal" type="button" class="btn btn-sm btn-success">+添加信息</button>
                    </td>
                </tr>
                <tr>
                    <th>ID</th>
                    <th>用户名</th>
                    <th>密码</th>

                    <c:if test="${requestScope.batchName.equals('User')}">
                        <th>电子邮箱</th>
                        <th>性别</th>
                        <th>手机号</th>
                        <th>住址</th>
                        <th>生日</th>
                        </c:if>
                </tr>
                <c:forEach items="${requestScope.studentList}" var="s" varStatus="userStatus" >
                    <tr id="tr${s.getId()}">
                        <td>${s.getId()}</td>
                        <td>${s.getUname()}</td>
                        <td>${s.getUpwd()}</td>
                        <td>${s.getUemail()}</td>
                        <td>${s.getUgender()}</td>
                        <td>${s.getUphone()}</td>
                        <td>${s.getUarea()}</td>
                        <td>${s.getUbirth()}</td>
                        <td>
                            <a class="link_showAddModal" href="javascript:showModifyModal('#tr${s.getId()}');">编辑</a>
                            <a href="javascript:deleteStudent('${s.getId()}','${requestScope.batchName}');">删除</a>
                        </td>
                    </tr>
                </c:forEach>

            </table>

            <!-- Modal -->
            <div class="modal fade" id="add_modal" tabindex="-1">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title text-success" id="myModalLabel">添加新用户</h4>
                        </div>
                        <div class="modal-body">
                            <form class="form-inline" id="add_form">
                                <label for="Uname">用户名：</label>
                                <input id="Uname" type="text" name="Uname" placeholder="输入用户名" class="form-control sinfo">
                                <br><br>
                                <label for="Upwd">密码：</label>
                                <input id="Upwd" type="text" name="Upwd" placeholder="在此输入密码" class="form-control sinfo">
                                <br><br>
                                <c:if test="${requestScope.batchName.equals('User')}">
                                    <label for="Uemail">邮箱：</label>
                                    <input id="Uemail" type="email" name="Uemail" placeholder="在此输入邮箱" class="form-control sinfo">
                                    <br><br>
                                    <input id="optins" type="hidden" name="optins" value="User" class="form-control sinfo">
                                </c:if>
                                <input id="optins" type="hidden" name="optins" value="Admin" class="form-control sinfo">


                                <input id="ibatch" name="sbatch" type="text" readonly class="form-control" value="<%=request.getAttribute("batchName")%>">

                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-warning" data-dismiss="modal">取消</button>

                            <button type="button" id="btn_add" class="btn btn-primary" >保存添加</button>
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal fade" id="modify_modal" tabindex="-1">
                <div class="modal-dialog">
                    <div class="bg-warn modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title text-danger" id="myModalLabel">编辑用户信息</h4>
                        </div>
                        <div class="modal-body">
                            <form class="form-inline" id="modify_form">
                                <label hidden="true" for="irollno">学号：</label>
                                <input id="irollno" value="${a}" type="hidden" name="srollno" readonly class="form-control">
                                <br><br>
                                <label for="Uname">用户名：</label>
                                <input id="Uname" type="text" name="Uname"  class="form-control">
                                <br><br>
                                <label for="Upwd">密码：</label>
                                <input id="Upwd" type="text" name="Upwd" class="form-control">
                                <br><br>
                                <c:if test="${requestScope.batchName.equals('User')}">
                                    <label for="Uemail">邮箱：</label>
                                    <input id="Uemail" type="email" name="Uemail" class="form-control">
                                    <br><br>
                                    <input id="optins" type="hidden" name="optins" value="User" class="form-control sinfo">
                                </c:if>
                                <input id="optins" type="hidden" name="optins" value="Admin" class="form-control sinfo">

                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-warning" data-dismiss="modal">取消</button>
                            <button type="button" id="btn_modify" class="btn btn-danger">保存修改</button>
                        </div>
                    </div>
                </div>
            </div>


        </div>
    </body>
</html>
